﻿using System;

namespace YArchitech.MEP
{
	public class HYPipe : HYTube
	{
		public int DN { get; set; }

		public double Diamieter
		{
			get
			{
				return this.m_Size.Diameter;
			}
			set
			{
				this.m_Size.Diameter = value;
			}
		}

		public double Thickness
		{
			get
			{
				return this.m_Thickness;
			}
			set
			{
				this.m_Thickness = value;
			}
		}

		public double Load
		{
			get
			{
				return this.m_Load;
			}
		}

		public HYMaterial Material { get; set; }

		public HYPipe()
		{
			this.Name = "管段";
			this.DN = 25;
			this.m_Size = new HYTubeSize(HYTubeShape.Round, 25.0, 320.0);
			this.m_Roughness = 2E-05;
		}

		public void SetSpecification(HYPipeSpecification spec)
		{
			this.DN = spec.DN;
			this.m_Size.Diameter = spec.Diameter;
			this.m_Thickness = spec.Thickness;
		}

		public override void Cal(HYSystemOption option)
		{
			if (this.Material != null)
			{
				this.m_Roughness = this.Material.Roughness;
			}
			base.Cal(option);
		}

		protected override void CalCoefficient()
		{
			this.m_Coefficient = 0.0;
		}

		public override void CalRm(double roughness, double density, double viscosity)
		{
			double d = base.Size.D;
			double rs = base.Size.Rs;
			base.Re = Hydrokinetics.Re(d, this.m_Velocity, viscosity);
			double x = Hydrokinetics.x_TF_CW(base.Re, roughness);
			base.Rm = Hydrokinetics.Rm(x, rs, this.m_Velocity, density);
		}

		protected double m_Thickness;

		protected double m_Load;
	}
}
